package down.xiaoheihe.work.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "tencent.cos")
public class COSConfig implements InitializingBean {

    //读取配置文件的内容
    @Value("${tencent.cos.file.baseUrl}")
    private String baseUrl;
    @Value("${tencent.cos.file.accessKey}")
    private String accessKey;
    @Value("${tencent.cos.file.secretKey}")
    private String secretKey;
    @Value("${tencent.cos.file.bucketName}")
    private String bucketName;
    @Value("${tencent.cos.file.regionName}")
    private String regionName;
    @Value("${tencent.cos.file.folderPrefix}")
    private String folderPrefix;

    //定义公共静态常量
    //存储桶名称
    public static String BUCKET_NAME;
    //secretId 秘钥id
    public static String SECRET_ID;
    //SecretKey 秘钥
    public static String SECRET_KEY;
    //腾讯云自定义文件夹名称
    public static String PREFIX;
    //访问域名
    public static String URL;
    //访问域名
    public static String REGION;

    @Override
    public void afterPropertiesSet() {
        BUCKET_NAME = bucketName;
        SECRET_ID = accessKey;
        SECRET_KEY = secretKey;
        PREFIX = folderPrefix;
        REGION = regionName;
        URL = baseUrl;
    }
}
